# 指定CMake最小版本  
cmake_minimum_required(VERSION 3.10)   

# 设置项目名和版本
project(TimeNow VERSION 1.0.0)

# 查找OpenCV  
set(OpenCV_DIR "A:/opencv-4.7.0/build/install") 
find_package(OpenCV 4.7.0 REQUIRED)

# 添加OpenCV头文件搜索路径  
include_directories("A:/opencv-4.7.0/build/install/include" 
                     "A:/opencv-4.7.0/build/install/include/opencv2")

# 添加timestamp模块  
add_library(timestamp SHARED src/timestamp.cpp)
target_include_directories(timestamp PUBLIC src/)

# 添加gui模块   
add_library(gui SHARED src/gui.cpp)  
target_include_directories(gui PUBLIC src/)
target_link_libraries(gui ${OpenCV_LIBS})

# 添加各lev模块
add_executable(lev0 src/lev0.cpp)
add_executable(lev1 src/lev1.cpp)  
add_executable(lev2 src/lev2.cpp)  
add_executable(lev3 src/lev3.cpp)   

# 设置各lev模块依赖timestamp,gui和OpenCV模块
target_link_libraries(lev0 timestamp gui ${OpenCV_LIBS})
target_link_libraries(lev1 timestamp gui ${OpenCV_LIBS})
target_link_libraries(lev2 timestamp gui ${OpenCV_LIBS})
target_link_libraries(lev3 timestamp gui ${OpenCV_LIBS})

# 将OpenCV的库文件复制到bin目录 
# 通过目录复制整个build文件夹
# install(DIRECTORY ${OpenCV_DIR}/x64/mingw/bin DESTINATION ${PROJECT_SOURCE_DIR}/bin USE_SOURCE_PERMISSIONS)  

# 指定安装路径
install(TARGETS timestamp gui lev0 lev1 lev2 lev3 DESTINATION ${PROJECT_SOURCE_DIR}/bin)

# 指定安装其他依赖库的路径
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/ DESTINATION ${PROJECT_SOURCE_DIR}/bin)